package com.corn.turtorial.provider.controller;

import com.corn.turtorial.provider.mapper.UserMapper;
import com.corn.turtorial.provider.service.User;
import com.corn.turtorial.provider.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : Jim Wu
 * @version 1.0
 * @function :
 * @since : 2022/5/5 11:09
 */

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/createUser")
    public Map<String, Object> createUser(String username) {
        userService.create(username);
        Map<String, Object> result = new HashMap<>();
        result.put("message", "success");
        return result;
    }

    @GetMapping("/createWithTransactionMessage")
    public Map<String, Object> createWithTransactionMessage(String username) throws Exception{
        userService.createWithTransactionMessage(username);
        Map<String, Object> result = new HashMap<>();
        result.put("message", "success");
        return result;
    }
}
